#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "file.h"
#include "normaltab.h"
#include "token.h"
#include "lexical.h"
#include "highlighter.h"
#include "quaternion.h"
#include "dag.h"
#include "syntax.h"
#include "symboltablewidget.h"
#include "objectcode.h"
#include <QMainWindow>
#include <QMessageBox>
#include <QShortcut>
#include <QToolBar>

#include <QDir>
#include <QDesktopServices>
#include <QUrl>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void showContent(QString content);
    string filetoString(QString filePath);
    //void setStyleMenuBar();
    QString loadStyleSheet(const QString &styleSheetFile);
    bool saveToFile(const QString& filePath, const QString& content);
    void updateTabTitle(int index);
    //void setupEditor(QTextEdit* editor, int index);
    void closeEvent(QCloseEvent* event);
private:
    Ui::MainWindow *ui;
    File file;
    QString filename;
    QAction *runAction;  // 菜单动作
    //QAction* save;
private slots:
    void OpenFile();
    void newTab();
    void onTabCloseRequested(int index);
    void saveCurrentFile();
    void lexicalAnalysis();
    bool saveCurrentTab();
    bool saveAsCurrentTab();
    bool maybeSaveAll();
    void setupEditor(QTextEdit* editor, int index);
    void optimize();                // 优化后的思源四
    void quaternary();              // 语法分析后的四元式
    void symbolTable();             // 符号表
    void objectCode();              // 目标代码
    void onRunActionTriggered();    // 运行
    //bool maybeSave(int index);
};
#endif // MAINWINDOW_H
